#include "processbar.h"
#define FILESIZE 1024*1024*1024

//模拟场景：下载任务
void download(callback_t cb)
{
    srand(time(NULL)^1023);
    int total = FILESIZE;
    while(total)
    {
        usleep(10000);
        int one = rand()%(1024*1024);
        total -= one;
        if(total < 0) total = 0;

        int doned = FILESIZE - total;
        double rate = ((double)doned / (double)(FILESIZE)) * 100.00;
        cb(rate);
    }
    //这里直接调用函数也是可以的
    //process_flush_a(rate);
    
    printf("\n");
}


int main()
{
   // process();
  //.autorelabel  download(process_flush_a);

    
    download(process_flush_b);
    return 0;
}
